<?php
/* [DoYouHaoBaby!] (C)Dianniu From 2010.
   this($)*/

!defined('DYHB_PATH') && exit;

class TemplateGtkGladeWidgetCompiler_GtkMenu extends TemplateGtkGladeWidgetCompiler_GtkMenuShell{

	protected function compileCreateWidget_(TemplateGtkGladeWidget $oObject){
		$sWidgetClass=$oObject->getWidgetClass();
		$sVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oObject);
		$sCompiled=parent::compileCreateWidget_($oObject);
		$this->setBool_($oObject,$sCompiled,'tearoff_state');// 撕下状态
		if(($sValue=$oObject->getProperty('tearoff_title'))!==null){$sCompiled.= "\t\t{$sVariableName}->set_title(\"{$sValue}\");";}// 撕下标题
		return $sCompiled;
	}

	protected function compileChildWidgetPacking_(TemplateGtkGladeWidget $oParentWidget,TemplateGtkGladeWidget $oChildWidget,TemplateGtkGladeWidgetPacking $oPacking){
		$sParentVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oParentWidget);// 父/子 窗体变量名
		$sChildWidgetVariableName='$'.TemplateGtkGlade::getWidgetVariableName($oChildWidget);
		$sChildWidgetName=$oChildWidget->getWidgetId();// 子窗体名
		if(($sLeft=$oPacking->getProperty('left_attach'))===null){$sLeft='-1';}// 上下左右
		if(($sRight=$oPacking->getProperty('right_attach'))===null){$sRight='-1';}
		if(($sTop=$oPacking->getProperty('top_attach'))===null){$sTop='-1';}
		if(($sBottom=$oPacking->getProperty('bottom_attach'))===null){$sBottom='-1';}
		$sCompiled="\t\t{$sChildWidgetVariableName}=self::getWidget('{$sChildWidgetName}',\$arrObjectForSignal);";
		if($sLeft<0 or $sTop<0){$sCompiled.="\t\t{$sParentVariableName}->append({$sChildWidgetVariableName});";}
		else{$sCompiled.="\t\t{$sParentVariableName}->attach({$sChildWidgetVariableName},{$sLeft},{$sRight},{$sTop},{$sBottom});";}
		return $sCompiled;
	}

	static public function regToProcessorManager(ITemplateObjProcessorManager $oManager){
		$oManager->regProcessor(str_replace('TemplateGtkGladeWidgetCompiler_','',__CLASS__),__CLASS__);
	}

}
